using System;
using System.Windows;
using System.Windows.Media.Animation;

namespace WPFPractice.Dialogs
{
	public class MaskDialogBase : Window
	{
		private readonly Window _parentWindow;

		public MaskDialogBase (Window parentWindow = null)
		{
			_parentWindow = parentWindow ?? Application.Current.MainWindow;
			Loaded += OnLoaded;
		}

		private void OnLoaded(object sender, RoutedEventArgs e)
		{
			if(_parentWindow != null)
			{
				Left = _parentWindow.Left;
				Top = _parentWindow.Top;

				double newWidth = _parentWindow.ActualWidth;
				double newHeight = _parentWindow.ActualHeight;
				//Width = newWidth;
				//Height = newHeight;

				DoubleAnimation widthAnimation = new (newWidth, TimeSpan.FromSeconds(0.5));
				DoubleAnimation heightAnimation = new (newHeight, TimeSpan.FromSeconds(0.5));
				BeginAnimation(WidthProperty, widthAnimation);
				BeginAnimation(HeightProperty, heightAnimation);

				//Storyboard storyboard = new Storyboard();
				//storyboard.Children.Add(widthAnimation);
				//storyboard.Children.Add(heightAnimation);
				//Storyboard.SetTarget(widthAnimation, this);
				//Storyboard.SetTarget(heightAnimation, this);
				//Storyboard.SetTargetProperty(widthAnimation, new PropertyPath(WidthProperty));
				//Storyboard.SetTargetProperty(heightAnimation, new PropertyPath(HeightProperty));
				//storyboard.Begin();

				if(_parentWindow.WindowState == WindowState.Maximized)
				{
					WindowState = WindowState.Maximized;
				}
			}
		}
	}
}
